<?php
namespace app\serveruser\service\menu;

use \app\manage\service\ApiBase;
/**
 * 应用菜单分类管理: 如后台菜单,个人中心菜单等
 * @author adv30 <adv30@126.com> 2017年6月1日9:26:23
 */
class MenuCate extends ApiBase
{
    protected $menuCateValidate = '\app\serveruser\validate\MenuCate';
    protected $menuCateLogic = '\app\serveruser\logic\MenuCate';
    // 为某一个应用增加一个菜单分类
    public function add(): array
    {
        $data = $this->haveIssetReceiveData(['app_id'=>'0', 'name'=>' ', 'name_cn'=>' ']);
        return $this->stepRun($data, 'add', 'add');
    }
    // 禁用某一应用的某一菜单分类
    public function stop(): array
    {
        $data = $this->haveIssetReceiveData(['id'=>'','name'=>'']);
        if(array_eq($data, '', ['name','id'])){
            return verify_err($data, 'name,id至少要传一个');
        }
        return $this->stepRun($data, 'stop', 'stop');
    }
    // 获取某一应用所有的可用菜单分类列表(不分页)
    public function listByApp(): array
    {
        $data = $this->haveIssetReceiveData(['app_id'=>' ']);
        return $this->stepRun($data, 'listByApp', 'listByApp');
    }
    // 获取所有可用的菜单分类列表
    public function list(): array
    {
        $data = $this->haveIssetReceiveData(['page'=>1, 'list_rows'=>'']);
        return $this->stepRun($data, 'list', 'list');
    }
    // 启用某一应用的某一菜单分类
    public function start(): array
    {
        $data = $this->haveIssetReceiveData(['id'=>'','name'=>'']);
        if(array_eq($data, '', ['name','id'])){
            return verify_err($data, 'name,id至少要传一个');
        }
        return $this->stepRun($data, 'start', 'start');
    }
    // 获取某一应用所有的菜单分类列表(不分页)
    public function listAllByApp(): array
    {
        $data = $this->haveIssetReceiveData(['app_id'=>' ']);
        return $this->stepRun($data, 'listAllByApp', 'listAllByApp');
    }
    // 编辑一个菜单分类
    public function edit(): array
    {
        $data = $this->haveIssetReceiveData(['id'=>'0', 'name'=>'', 'name_cn'=>'']);
        if(array_eq($data, '', ['name','name_cn'])){
            return verify_err($data, 'name,name_cn至少要传一个');
        }
        return $this->stepRun($data, 'edit', 'edit');
    }
}
